#include "rreye.h"

RREye::RREye()
{
    h_s = 1.0f;
    e_coord = RRSetVec3(0.0f, 14.0f, -30.0f);
    e_dir = RRSetVec3(1.0f, 1.0f, 1.0f);
    e_up = RRSetVec3(0.0f, 1.0f, 0.0f);
    e_lookat = RRSetVec3(-0.1, -0.4f, 1.0f);
}

float RREye::rrGetScreenPos()
{
    return h_s;
}

void RREye::rrSetEyeCoord(RRVec3 arg)
{
    e_coord = arg;
}

void RREye::rrSetEyeUp(RRVec3 arg)
{
    e_up = arg;
}

void RREye::rrSetLookAt(RRVec3 arg)
{
    e_up = arg;
}

RRVec3 RREye::rrGetEyeCoord()
{
    return e_coord;
}

RRVec3 RREye::rrGetEyeDir()
{
    return e_dir;
}

void RREye::rrGenerateEye(RRVec3 arg)
{
    //変換前の視線
    RRVec3 d0;
    d0.x = arg.x;
    d0.y = arg.y;
    d0.z = arg.z;
    d0 = RRNormalize(d0);

    RRVec3 Ze;   //注視点への単位ベクトル
    Ze = RRNormalize(e_lookat);
    RRVec3 Xe;
    Xe = RRNormalize(RRCrossProduct(e_up, Ze));
    RRVec3 Ye;
    Ye = RRCrossProduct(Ze, Xe);
    e_dir.x = Xe.x * d0.x + Ye.x * d0.y + Ze.x * d0.z;
    e_dir.y = Xe.y * d0.x + Ye.y * d0.y + Ze.y * d0.z;
    e_dir.z = Xe.z * d0.x + Ye.z * d0.y + Ze.z * d0.z;
}

